package Admin;

import com.dushibao.admin.AdminApplication;
import com.dushibao.admin.model.Admin;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.*;

@SpringBootTest(classes = AdminApplication.class)
@AutoConfigureMockMvc
public class AdminControllerMock {
    @Autowired
    private MockMvc mockMvc;

    @Test
    void getById() throws Exception {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.put("id", Collections.singletonList("1"));
        MockMvcUtils.doGet(mockMvc,"/Admin/getById",params);
    }

    @Test
    void list() throws Exception {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        MockMvcUtils.doGet(mockMvc,"/Admin/list");
    }

    @Test
    void removeByIds() throws Exception {
        Map<String,Object> params = new HashMap<>();
        //params.put("ids", "104");
        MockMvcUtils.doPost(mockMvc,"/Admin/removeByIds",params);
    }

    @Test
    void saveOrUpdate() throws Exception {
        Admin admin = new Admin();
        MockMvcUtils.doPost(mockMvc,"/Admin/save",admin);
    }

    @Test
    void page(){
        MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
        MockMvcUtils.doGet(mockMvc,"/Admin/page",params);
    }
}
